package com.PTRS.dao;

import com.PTRS.entities.Coach;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ICoachDao {

    @Select("SELECT * FROM coach")
    @Results(
            id = "coachMap",value = {
                    @Result(id = true,column = "id",property = "coachID"),
                    @Result(column = "name",property = "coachName"),
                    @Result(column = "sex",property = "coachSex"),
                    @Result(column = "passwd",property = "coachPasswd"),
                    @Result(column = "intro",property = "coachIntro")
    }
    )
    List<Coach> findAll();

    @Insert("INSERT INTO coach(name, sex, passwd, intro) VALUES (#{coachName},#{coachSex},#{coachPasswd},#{coachIntro})")
    void insertCoach(Coach coach);

    @Delete("DELETE FROM coach WHERE id=#{coachID}")
    void deleteCoach(int coachID);

    @Update("UPDATE coach SET name=#{coachName},sex=#{coachSex},passwd=#{coachPasswd},intro=#{coachIntro} WHERE id=#{coachID}")
    void updateCoach(Coach coach);

    @Select("SELECT * FROM coach WHERE id=#{coachID}")
    @ResultMap("coachMap")
    void findCoachByID(int coachID);
}
